package com.sanrenzu.chunbo.ui.foodagency;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.sanrenzu.chunbo.R;
import com.sanrenzu.chunbo.bean.gy.ChefListBean;

import java.util.List;

/**
 * Created by Administrator on 2016/8/31 0031.
 */
public class ChefAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context mContext;
    private List<ChefListBean> list;
    private LayoutInflater inflater;

    public ChefAdapter(Context mContext, List<ChefListBean> list) {
        this.mContext = mContext;
        this.list = list;
        inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.recycleview_chef_foodagency, parent, false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        MyViewHolder mHolder = (MyViewHolder) holder;
        mHolder.textView_name_chef_foodAgency.setText(list.get(position).getName());
        mHolder.textView_summary_chef_foodAgency.setText(list.get(position).getSummary());
        mHolder.simpleDraweeView_chef_foodAgency.setImageURI(list.get(position).getPicUrl() + "");
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        private SimpleDraweeView simpleDraweeView_chef_foodAgency;
        private TextView textView_name_chef_foodAgency;
        private TextView textView_summary_chef_foodAgency;

        public MyViewHolder(View itemView) {
            super(itemView);
            simpleDraweeView_chef_foodAgency =
                    (SimpleDraweeView) itemView.findViewById(R.id.simpleDraweeView_chef_foodAgency);
            textView_name_chef_foodAgency =
                    (TextView) itemView.findViewById(R.id.textView_name_chef_foodAgency);
            textView_summary_chef_foodAgency =
                    (TextView) itemView.findViewById(R.id.textView_summary_chef_foodAgency);
        }
    }
}
